import { defineStore } from 'pinia'
import { constantRouter } from '@/router/routes.ts'

const useUserStore = defineStore('User', {
  state: (): any => {
    return {
      menuRoutes: constantRouter,
      username: localStorage.getItem('user')?.replace(/"/g, ''),
      avatar: localStorage.getItem('avatar'),
    }
  },
  actions: {
    userLogout() {
      localStorage.removeItem('user')
      localStorage.removeItem('smart_admin_user_token')
      this.username = ''
    },
  },
})

export default useUserStore
